//
//  ViewController.m
//  六棱形
//
//  Created by 吕清毅 on 2018/3/28.
//  Copyright © 2018年 lqy. All rights reserved.
//

#import "ViewController.h"
#import "DrawSixLineStar.h"

#define Margin 50
#define Width [UIScreen mainScreen].bounds.size.width
#define Height [UIScreen mainScreen].bounds.size.height
#define zzColor(r, g, b)  [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define zzColorRGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
// 随机色
#define zzRandomColor  zzColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
#define DEGREES_TO_RADIANS(angle) ((angle) / 180.0 * M_PI)

@interface ViewController ()

@property (nonatomic, strong) DrawSixLineStar *drawView;//画图的view
@property (nonatomic, assign) float View_width;
@property (nonatomic, assign) float View_height;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    //分支
    NSLog(@"c=1");
    CGPoint yPoint = CGPointMake(Width/2, Width/2 + 100);
    CGFloat startAngle = 0;
    CGFloat endAngle = 0;
    float r = Width/4;
    float sum = 360;
    for (int i = 0; i < 6; i++) {
        
        float bili = 60 / sum;
        endAngle = startAngle + bili * M_PI*2;
        CAShapeLayer *layer = [CAShapeLayer layer];
        UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:yPoint radius:r startAngle:startAngle endAngle:endAngle clockwise:YES];
        [path addLineToPoint:yPoint];
        [path closePath];
        
        layer.path = path.CGPath;
        layer.fillColor = zzRandomColor.CGColor;
        layer.strokeColor = [UIColor clearColor].CGColor;
        [self.view.layer addSublayer:layer];

        
        startAngle = endAngle;
    }

}

#pragma mark - 画六芒星
- (void)drawShape
{
    self.drawView = [[DrawSixLineStar alloc]initWithFrame:CGRectMake(0, 150, Width, 400)];
    self.drawView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.drawView];
    NSArray *levelArray = @[@"A",@"A",@"A",@"A",@"A",@"A"];
    [self.drawView drawLiuMangXing:nil and:levelArray];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
